import { useRequire } from "@/api/instance";
import { TreeOptionData } from "tdesign-vue-next";
import { CustomerScript } from "$/entity";

export const customerScriptListApi = (id: string) => {
  return useRequire<Array<TreeOptionData>>("/api/customer_script/tree", {
    id
  });
};

export const customerScriptAddApi = (data: CustomerScript) => {
  return useRequire<void>("/api/customer_script/add", {
    data
  });
};

export const customerScriptRenameApi = (id: string, name: string) => {
  return useRequire<void>("/api/customer_script/rename", {
    id,
    name
  });
};

export const customerScriptDeleteApi = (id: string) => {
  return useRequire<void>("/api/customer_script/delete", {
    id
  });
};

export const customerScriptContentGetApi = (id: string) => {
  return useRequire<string>("/api/customer_script/content/get", {
    id
  });
};

export const customerScriptContentSaveApi = (id: string, content: string) => {
  return useRequire<void>("/api/customer_script/content/save", {
    id,
    content
  });
};
